<%@ page language="java" import="java.util.*" contentType="text/html;charset=utf-8" %>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="<%=basePath %>js/jquery.js"></script>
<title>考试系统</title>
<style type="text/css">
<!--
body {
	margin-left: 3px;
	margin-top: 0px;
	margin-right: 3px;
	margin-bottom: 0px;
}
.STYLE1 {
	color: #e1e2e3;
	font-size: 12px;
}
.STYLE6 {color: #000000; font-size: 12; }
.STYLE10 {color: #000000; font-size: 12px; }
.STYLE19 {
	color: #344b50;
	font-size: 12px;
}
.STYLE21 {
	font-size: 12px;
	color: #3b6375;
}
.STYLE22 {
	font-size: 12px;
	color: #295568;
}
-->
</style>
		
		<s:if test = "paper.id != null">
		<script type="text/javascript">
		var flag ;
		function add(o){
			flag = o;
			var id = o;
			var par=${paper.id};
			$.get("../Teacher/TeacherAction!paperclazzadd.action?id="+id+"&paperId="+par,null,addcallback);
		}
		function addcallback(data){
			if(data != null){
				alert(data);
				$("#info"+flag).text("已添加");
				$("#add"+flag).hide();
				$("#delete"+flag).show();
			}
			else
				alert("添加失败！");
		}
		
		function ccdel(o){
			flag = o;
			var id = o ;
			var par=${paper.id};
			$.get("../Teacher/TeacherAction!delPaperClazz.action?id="+id+"&paperId="+par , null,ccdelcallback);
		}
		function ccdelcallback(data){
			if(data != null){
				alert(data);
				$("#info"+flag).text("");
				$("#add"+flag).show();
				$("#delete"+flag).hide();
			}
			else
				alert("删除失败！");
		}
		
		
		function addproblem(){
			location.href="../Teacher/addProblem.action?paperid="+${paper.id};
		}
		</script>
		</s:if>
		<script type="text/javascript">
		function info(i,cid){
			//window.open("../Teacher/TeacherAction!programInfo.action?id="+i,"","") 
			location.href="../Clazz/ClazzAction!StuList.action?id="+i;
		}
		
		function score(id){
			location.href="../Clazz/ClazzAction!StuScore.action?id="+id;
		}
		
		function paper(id){
			location.href="../Clazz/ClazzAction!getPaperBycid.action?id="+id;
		}
		
		var flag;
		function del(id,status){
			if(confirm("是否确定删除")){
				todel(id,status);
			}
		}
		
		function todel(id,status){
			flag = status;
			$.get("<%=request.getContextPath()%>/Clazz/ClazzAction!delClazz.action?id="+id,null,delcallback)
		}
		
		function delcallback(data){
			if(data != null){
				alert(data);
				alert(flag);
				$("#"+flag).hide();
			}
			else
				alert("删除失败！");
		}
		</script>
		
</head>
<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="24" bgcolor="#353c44"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="6%" height="19" valign="bottom"><div align="center"><img src="images/tb.gif" width="14" height="14" /></div></td>
                <td width="94%" valign="bottom"><span class="STYLE1"> 班级基本信息列表</span></td>
              </tr>
            </table></td>
            <td><div align="right"></div></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td><table width="600" border="0" cellpadding="0" cellspacing="1" bgcolor="#a8c7ce">
      <tr>
        <td width="10%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">编号</span></div></td>
        <td width="25%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">班号</span></div></td>
        <td width="25%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">专业</span></div></td>
        <td width="40%" height="20" bgcolor="d3eaef" class="STYLE6"><div align="center"><span class="STYLE10">
        	<s:if test="paper.id != null">	增加 &nbsp;&nbsp;</s:if>
        	查看</span></div></td>
      </tr>
      
      <s:iterator value="clazzList" id="clazz" status = "index">
	  <tr id="<s:property value="#index.index" />">
        <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center"> <s:property value="#index.index+1" /> </div></td>
        <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center"><s:property value="#clazz.classnum" /></div></td>
        <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center"><s:property value="#clazz.classname" /></div></td>
		<td height="20" bgcolor="#FFFFFF"><div align="center"><span class="STYLE21">
		<s:if test="paper.id != null">
		      <span id="info<s:property value="#clazz.id" />"></span>
        <s:if test="#clazz.id in dataset">
                <input type="button" id ="add<s:property value="#clazz.id" />" value="添加" style="display:none"  onclick="add(<s:property value="#clazz.id" />)"/>
                <input type="button" id ="delete<s:property value="#clazz.id" />" value = "删除"  onclick="ccdel(<s:property value="#clazz.id" />)"/>
        </s:if>
        <s:else>
                <input type="button" id ="add<s:property value="#clazz.id" />" value="添加"  onclick="add(<s:property value="#clazz.id" />)"/>
                <input type="button" id ="delete<s:property value="#clazz.id" />" value = "删除" style="display:none" onclick="ccdel(<s:property value="#clazz.id" />)"/>
        </s:else>
		</s:if>
			<a href="#" onclick="info(<s:property value="#clazz.id" />)">详细</a>
			<a href="#" onclick="paper(<s:property value="#clazz.id" />)">考试</a>
			<a href="#" onclick="score(<s:property value="#clazz.id" />)">分数</a>
			<a href="#" onclick="del(<s:property value="#clazz.id" />,<s:property value="#index.index" />)">删除</a>
			</span></div></td>
	  </tr>
	  </s:iterator>
    </table></td>
  </tr>
</table>
<s:if test="paper.id != null">
<input type="button" value="添加题目" onclick="addproblem()" />
</s:if>
 <s:property value="paper.id"/>
</body>
</html>
